package com.ganzalang.gmall.common.api;

import lombok.Data;

/**
 * @description: 通用返回对象
 * @author: ganzalang
 */
@Data
public class CommonResult<T> {
    /**
     * 错误码
     */
    private long code;
    /**
     * 信息
     */
    private String message;
    /**
     * 返回的数据
     */
    private T data;

    public CommonResult() {

    }

    public CommonResult(long code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> CommonResult<T> success(T data) {
        return new CommonResult<T>(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage(), data);
    }

}
